<template>
	<view>
		<view class='nav acea-row acea-row' :class="{borderShow:isBorader}" v-if="menus.length">
			<block v-for="(item,index) in menus" :key="index">
				<view class='item' @click="menusTap(item.info[1].value)">
					<view class='pictrue'>
						<image :src='item.img'></image>
					</view>
					<!--<view class="menu-txt">{{item.info[0].title}}</view>-->
					<view class="menu-value">{{item.info[0].value}}</view>
				</view>
			</block>
		</view>
		<view class="nav acea-row acea-row" :class="{borderShow:isBorader}" v-if="isIframe && !menus.length">
			<view class='item'>
				<view class='pictrue default'>
					<text class="iconfont icon-icon25201"></text>
				</view>
				<view class="menu-txt">默认</view>
			</view>
		</view>
	</view>
</template>

<script>
	let app = getApp()
	import { goPage } from '@/libs/order.js'
	export default {
		name: 'c_menus',
		props: {
			dataConfig: {
				type: Object,
				default: () => {}
			},
			activeName: {
				type: String,
				default: ''
			}
		},
		watch: {
			activeName: {
				handler(nVal, oVal) {
					if (nVal == this.name && app.globalData.isIframe) {
						this.isBorader = true
					} else {
						this.isBorader = false
					}
				},
				deep: true
			}
		},
		data() {
			return {
				menus:this.dataConfig.imgList.list,
				isBorader:false,
				name: this.$options.name,
				isIframe:false
			};
		},
		created() {
			this.isIframe = app.globalData.isIframe
		},
		mounted() {},
		methods: {
			menusTap(url) {
				goPage().then(res=>{
					if(url.indexOf("http") != -1){
						// #ifdef H5
						location.href = url
						// #endif
					}else{
						if(['/pages/goods_cate/goods_cate','/pages/order_addcart/order_addcart','/pages/user/index'].indexOf(url) == -1){
							uni.navigateTo({
								url:url
							})
						}else{
							uni.switchTab({
								url:url
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.nav {
		background-color: #fff;
		padding-bottom: 30rpx;
		.item {
			padding: 2%;
			margin-top: 30rpx;
			width: 29%;
			margin-left: 3%;
			box-shadow: 0 0 2px #9C814E;
			text-align: center;
			.pictrue {
				padding-top: 20rpx;
				width: 148rpx;
				height: 158rpx;
				margin: 0 auto;
				&.default{
					background-color: #ccc;
					text-align: center;
					line-height: 90rpx;
					.iconfont{
						font-size: 40rpx;
					}
				}

				image {
					width: 100%;
					height: 100%;
				}
			}

			.menu-txt {
				margin-top: 15rpx;
				color: #D3AF6B;
				font-size: 36rpx;
			}
			.menu-value{
				margin-top: 15rpx;
				color: #666;
				font-size: 24rpx;
			}

			&.four {
				width: 25%;

				.pictrue {
					width: 90rpx;
					height: 90rpx;
				}
			}
		}
	}
</style>
